package org.example.music_manage_system.mapper;

import org.example.music_manage_system.pojo.Music;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MusicMapper {
//添加曲目
@Insert("insert into yl_music.music(title,content,songs,category_id,create_user,create_time,update_time, play_url,states) " +
        "values(#{title},#{content},#{songs},#{categoryId},#{createUser},#{createTime},#{updateTime},#{playUrl},#{states})")
         void add(Music music);
//查找曲子
    @Select("select * from yl_music.music where id=#{id}")
    Music findById(Integer id);
//修改曲子
    //注意songs=#{songs}
    @Insert("update yl_music.music set title=#{title},content=#{content},songs=#{songs},category_id=#{categoryId}," +
            "update_time=#{updateTime} ,play_url=#{playUrl},states=#{states}where id=#{id}")
    void update(Music music);
//删除曲子
    @Delete("delete from yl_music.music where id=#{id}")
    void delete(Integer id);
//分页显示曲子
List<Music> list(Integer userId, Integer categoryId, String states);


}
